﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Reflection.Emit;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
using static 定时提醒.Form1;
namespace 定时提醒
{
    public partial class Form2 : Form
    {
        private string parameterValue = "";
        private AlarmManager.AlarmItem currentAlarm;
        private int alarmIndex = -1;

        public Form2()
        {
            InitializeComponent();
        }

        /// <summary>
        /// 设置闹钟信息（从Form1传递过来）
        /// </summary>
        /// <param name="alarm">闹钟对象</param>
        /// <param name="index">闹钟在列表中的索引</param>
        public void SetAlarmInfo(AlarmManager.AlarmItem alarm, int index)
        {
            currentAlarm = alarm;
            alarmIndex = index;

            // 显示闹钟信息
            //label1.Text = $"修改闹钟 {alarm.Time:HH:mm} 的提示信息";
            //textBox1.Text = alarm.Message;

            dtpAlarmTime.Value = alarm.Time;
            txtAlarmMessage.Text = alarm.Message;
            chkRepeat.Checked = alarm.IsRepeat;
            chkPrompt.Checked = alarm.IsPrompt;
            chkPromptSound.Checked = alarm.PromptSound;
            chkEnabled.Checked = alarm.IsEnabled;
        }

        public DateTime GetAlarmTime()
        {
            return dtpAlarmTime.Value;
        }
        public string GetAlarmMessage()
        {
            return txtAlarmMessage.Text;
        }
        public bool GetAlarmRepeat()
        {
            return chkRepeat.Checked;
        }
        public bool GetAlarmPrompt()
        {
            return chkPrompt.Checked;
        }
        public bool GetAlarmPromptSound()
        {
            return chkPromptSound.Checked;
        }
        public bool GetAlarmEnabled()
        {
            return chkEnabled.Checked;
        }

        public int GetAlarmIndex()
        {
            return alarmIndex;
        }

        private void button2_Click(object sender, EventArgs e)
        {
            // 验证输入
            if (string.IsNullOrWhiteSpace(txtAlarmMessage.Text))
            {
                MessageBox.Show("提示信息不能为空！", "错误", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            // 设置对话框结果为OK，表示用户确认了修改
            this.DialogResult = DialogResult.OK;

            // 关闭Form2
            this.Close();
        }
    }
}
